window.addEventListener("click", callback());
function callback() {
  const divList = [];
  let i = 0;
  const colors = ["red", "blue", "green", "yellow"];
  let count = 0;
  return function (e) {
    const scrollX =
      document.documentElement.scrollLeft || document.body.scrollLeft;
    const scrollY =
      document.documentElement.scrollTop || document.body.scrollTop;
    const div = createTag();
    divList.push(div);
    div.style.top = e.clientY + scrollY + "px";
    div.style.left = e.clientX + scrollX + "px";
    div.style.color = colors[i];
    count++;
    div.innerText = `第${count}次点击`;
    i++;
    if (i > 3) {
      i = 0;
    }
    document.body.appendChild(div);
    setTimeout(function () {
      document.body.removeChild(div);
    }, 300);
  };
}
// 创建漂浮标签
function createTag() {
  const div = document.createElement("div");
  div.classList.add("animation");
  return div;
}
